#ifndef __SOC_COMM_DEF_H__
#define __SOC_COMM_DEF_H__

#include "framework_global.h"

//定义GPIO
//PORT eg: A B C ...
#define GPIO_PORT_DEF(port, pin) GpioPortPin(GpioPort::Port##port, pin)

/// @brief 支持的外设类型
enum class SocPeriphType
{
    Gpio = 0,
    Uart,
    Timer,
    Adc,
    Exti,
    Can,
    IIC
};

//GPIO
enum class GpioPort
{
    None = -1,
    PortA = 0,
    PortB,
    PortC,
    PortD,
    PortE,
    PortF,
    PortG,
    PortH,
    PortI,
    
    MAX
};
#define SOC_GPIO_MAX  (int)GpioPort::MAX 

//外部中断
enum class GpioExtiDevId
{
    None = -1,
    Line0,
    Line1,
    Line2,
    Line3,
    Line4,
    Line5,
    Line6,
    Line7,
    Line8,
    Line9,
    Line10,
    Line11,
    Line12,
    Line13,
    Line14,
    Line15,
    Max
};
#define GPIO_EXTI_MAX (int)GpioExtiDevId::Max

//GPIO PIN
class GpioPortPin 
{
public:
    explicit GpioPortPin()
    {

    }
    
    explicit GpioPortPin(GpioPort port, uint8_t pin)
    {
        Config(port, pin);
    }

    virtual ~GpioPortPin() {}

public:
    inline static GpioPortPin None()
    {
        GpioPortPin port(GpioPort::None, 0);
        return port;
    }

    inline GpioPortPin& Config(GpioPort port, uint8_t pin)
    {
        Port = port;
        Pin = pin;
        return *this;
    }

    inline void SetNone()
    {
        Port = GpioPort::None;
    }

    inline bool IsNone()
    {
        return Port == GpioPort::None;
    }

    inline bool Equals(const GpioPortPin &gp)
    {
        return Port == gp.Port && Pin == gp.Pin;
    }

public:
    GpioPort Port = GpioPort::None;
    uint8_t Pin;
};

#if false 
enum class GpioPin
{
    Pin0 = 0,
    Pin1,
    Pin2,
    Pin3,
    Pin4,
    Pin5,
    Pin6,
    Pin7,
    Pin8,
    Pin9,
    Pin10,
    Pin11,
    Pin12,
    Pin13,
    Pin14,
    Pin15
};
#endif 

//UART
enum class UartDevId
{
    None = -1,
    DevUART1 = 0,
    DevUART2,
    DevUART3,
    DevUART4,
    DevUART5,
    DevUART6,
    DevUART7,
    DevUART8,
    Max
};
#define SOC_UART_MAX (int)UartDevId::Max

//TIMER
enum class TimerDevId
{
    None = -1,
    Timer1 = 0,
    Timer2,
    Timer3,
    Timer4,
    Timer5,
    Timer6,
    Timer7,
    Timer8,
    Timer9,
    Timer10,
    MAX
};
#define SOC_TIMER_MAX (int)TimerDevId::MAX

//ADC
enum class AdcDevId
{
    None = -1,
    Adc1 = 0,
    Adc2,
    Adc3,
    Adc4,
    Adc5,
    Max
};
#define SOC_ADC_MAX (int)AdcDevId::Max

#endif // __SOC_COMM_DEF_H__
